define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'withdrawal/index',
        add_url: 'withdrawal/add',
        edit_url: 'withdrawal/edit',
        delete_url: 'withdrawal/delete',
        export_url: 'withdrawal/export',
        modify_url: 'withdrawal/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh'],
                cols: [[
                    {field: 'id', title: 'id', search: false},
                    {field: 'nickname', title: '昵称', search: false},
                    {field: 'real_name', title: '真实姓名', search: false},
                    {field: 'phone', title: '手机号'},
                    {field: 'type', title: '类型',selectList: {1: '分销商',2: '陪玩'}},
                    {field: 'money', title: '提现金额', search: false},
                    {field: 'status', title: '状态',selectList: {0:'待审核',1: '通过',2: '拒绝'}},
                    {field: 'desc', title: '提现备注', search: false},
                    {field: 'reason', title: '拒绝原因', search: false},
                    {field: 'create_time', title: '申请时间', search: false},
                    {title: '操作', templet: function (d) {
                        if(d.status == 1 || d.status == 2){
                            return '<button class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" >通过</button>  <button class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" >驳回</button>';
                        }else{
                            return '<button class="layui-btn layui-btn-xs layui-btn-success" data-request="withdrawal/adopt_url?id='+d.id+'"  data-title="确定通过吗？" >通过</button>' +
                                '<button class="layui-btn layui-btn-xs layui-btn-danger" data-open="withdrawal/reject_url?id='+d.id+'"  data-title="驳回" >驳回</button>'
                        }
                        }
                    },

                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        reject_url: function () {
            ea.listen();
        },
    };
    return Controller;
});